package com.pbking.facebook.delegates.data
{
	import com.pbking.facebook.Facebook;
	import com.pbking.facebook.delegates.FacebookDelegate;

	/**
	 * delegate for calling data.setHashValue  
 	 * reference: http://wiki.developers.facebook.com/index.php/Data_Store_API_documentation
	 * 
	 * @author sol wu
	 */
	public class SetHashValueDelegate extends FacebookDelegate
	{
		public var objid:Number;
		
		public function SetHashValueDelegate(facebook:Facebook, objType:String, key:String, value:String, propName:String)
		{
			super(facebook);
			if (objType != "") { fbCall.setRequestArgument("obj_type", objType); }
			if (key != "") { fbCall.setRequestArgument("key", key); }
			if (value != "") { fbCall.setRequestArgument("value", value); }
			if (propName != "") { fbCall.setRequestArgument("prop_name", propName); }
			fbCall.post("facebook.data.setHashValue");
		}
		
		override protected function handleResult(result:Object):void
		{
			// object id of the created object
			objid = -1;
			// what if it failed?
			if (result) {
				// note:  why does facebook setHashValue() return obj_id in string, and createObject() return obj_id in number?				
				objid = Number(result);
			}
		}
		
	}
}